/** *****************  JAVA头文件说明  ****************
 * file name  :  MyBatisConfig.java
 * owner      :  xu
 * copyright  :  UMPAY
 * description:  
 * modified   :  2016-11-4
 * *************************************************/ 

package com.jflm.config;

import java.util.Properties;

import javax.sql.DataSource;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import com.github.pagehelper.PageHelper;


/** ******************  类说明  *********************
 * class       :  MyBatisConfig
 * @author     :  xuhuafeng
 * @version    :  1.0  
 * description :  MyBatis 配置
 * ************************************************/
@Configuration
//@AutoConfigureBefore(MybatisAutoConfiguration.class)
public class MyBatisConfig {
	
	private static final Logger log = LoggerFactory.getLogger(MyBatisConfig.class);
	
	@Bean
    public PageHelper pageHelper(DataSource dataSource) {
		log.info("注册MyBatis分页插件PageHelper");
        PageHelper pageHelper = new PageHelper();
        Properties p = new Properties();
        p.setProperty("offsetAsPageNum", "true");
        p.setProperty("rowBoundsWithCount", "true");
        p.setProperty("reasonable", "true");
        pageHelper.setProperties(p);
        return pageHelper;
    }

}
